package com.summer.typeToken;

import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.ArrayList;

public class TypeTokenTest {
	public static void main(String[] args) {
//		Type type = new TypeToken<ArrayList<String>>(){}.getType ();
		
		
//		Type mySuperClass = new ArrayList<String>() {}.getClass().getGenericSuperclass(); 
		Type mySuperClass = new TestType<String>().getClass().getGenericSuperclass();
//		Type type = ((ParameterizedType) mySuperClass).getActualTypeArguments()[0];
		ParameterizedType genericSuperclass =null;
		 if(mySuperClass instanceof ParameterizedType){
             genericSuperclass =(ParameterizedType) mySuperClass;
	      }else{
	             genericSuperclass =(ParameterizedType)new TestType<String>().getClass().getSuperclass().getGenericSuperclass();
	      }
		
		System.out.println(mySuperClass);
		
	}
	
	
	public static class TestType<T>{
		public T obj;
	}
}
